import 'package:custom_button_builder/custom_button_builder.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class AppButton extends StatelessWidget {
  final Function onPressed;
  final String? content;
  final double? width;
  final double? height;
  final double borderRadius;
  final Color backgroundColor;
  /// 禁止点击
  final bool disable;
  final Widget? child;
  final Decoration? decoration;

  const AppButton({
    super.key,
    required this.onPressed,
    this.content,
    this.width,
    this.height,
    this.borderRadius = 90,
    this.backgroundColor = Colors.green,
    this.disable = false,
    this.child,
    this.decoration
  });

  @override
  Widget build(BuildContext context) {
    return CustomButton(
      width: width ?? 150,
      height: height ?? 48,
      pressed: disable ? Pressed.pressed : Pressed.notPressed,
      decoration: decoration,
      borderRadius: borderRadius,
      backgroundColor: decoration == null ? (disable ? Colors.grey : backgroundColor) : null,
      animate: true,
      onPressed: () {
        if (disable) return;
        onPressed.call();
      },
      child: child ?? Center(
        child: Text(content ?? '', style: const TextStyle(color: Colors.white)),
      ),
    );
  }
}
